<markdown>
# 异步关闭

点击确定后异步关闭对话框，使用 `beforeOk` 返回 promise 可实现异步关闭
</markdown>

<template>
  <x-space>
    <x-button type="primary" @click="confirm">Confirm</x-button>
  </x-space>
</template>

<script setup>
import { Modal, Message } from 'x-ui-vue3'

function confirm() {
  Modal.confirm({
    title: 'Confirm',
    content: 'confirm confirm confirm',
    beforeOk() {
      return new Promise(resolve => {
        const close = Message.loading('Loading……')
        setTimeout(() => {
          close()
          resolve()
        }, 2000)
      })
    }
  })
}
</script>
